﻿using Microsoft.AspNetCore.Http;

namespace Open.Core.Identity.Implements
{

    public class IdentityServer : IIdentityServer
    {

        private IHttpContextAccessor _context;
        public IdentityServer(IHttpContextAccessor context)
        {
            _context = context;
        }

        public async Task<int> GetTenancyName()
        {
            return Convert.ToInt32(this._context.HttpContext.User.FindFirst("tenancy_name").Value);
        }

        public string GetUserId()
        {
            return _context.HttpContext.User.FindFirst("sub").Value;
        }
    }
}
